package com.Maykk.Demo05;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @ClassName: ClientSend
 * @Description: TODO TCP 发送数据
 * @Author: MaykkStar@163.com
 */
public class ClientSend {
    public static void main(String[] args) throws IOException {
        // 实例化 Socket 对象
        Socket socket = new Socket("Star", 9527);

        // 创建输出流用于写入传输数据
        OutputStream outputStream = socket.getOutputStream();

        // 发送数据
        byte[] data = "Hello JavaSE TCP NetWork!~".getBytes();
        outputStream.write(data);

        // 释放资源
        socket.close();
    }
}
